package com.gitee.deament.server.core.data;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * zortSet数据结构
 * @author deament
 */
public class ZSortSet  implements Serializable {
    private volatile ArrayList<ZSortSetMember> data;

    public ArrayList<ZSortSetMember> getData() {
        return data;
    }

    public synchronized void setMember(ZSortSetMember member){
        if(data==null){
            data= new ArrayList<>();
        }
        ZSortSetMember dbmember=  getMember(member.getMember());
        if(dbmember!=null){
            dbmember.setScore(member.getScore());
            return ;
        }
        data.add(member);
    }
    public ZSortSetMember getMember(String member){
        if(data==null){
            return null;
        }
        for (ZSortSetMember datum : data) {
            if(datum.getMember().equals(data)){
                return datum;
            }
        }
        return null;
    }
}
